package com.gupao.javap6.pattern.proxy;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * TODO
 *
 * @author withinfly(45度C)
 * @date 2020/3/1 23:35
 */
@Data
@Accessors(chain = true)
public class ProxyTest {

    public static void main(String[] args) {

        IDynamicDataSourceProxy proxy = new IDynamicDataSourceProxy();
        IBasicMapper<UserEntity> mapper = proxy.getMapper(new UserServiceImpl());

        Integer userId = 100;

        System.out.println();
        System.out.println();
        UserEntity userEntity = new UserEntity()
                .setUserId(userId)
                .setUserName("withinfly")
                .setNickName("45度C");
        mapper.add(userEntity);
        System.out.println();

        mapper.add(new UserEntity()
                .setUserId(101)
                .setUserName("withinfly-101")
                .setNickName("45度C-101"));
        System.out.println();

        userEntity.setNickName("85°C");
        mapper.update(userEntity);
        System.out.println();

        mapper.select(userId);
        System.out.println();

        mapper.selectAll();
        System.out.println();

        mapper.delete(userId);
        System.out.println();

        mapper.selectAll();
        System.out.println();

    }

}
